/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package util;

/**
 *
 * @author Rdelacruz
 */
public class ThreadUtil {
    
    public static void main(String args[]) {
        System.out.println("INICIO H"+getIdentificadorHiloActual());
        ThreadUtil.dormirHilo(5000);
        System.out.println("FIN H"+getIdentificadorHiloActual());
    }
    
    //http://stackoverflow.com/questions/3294293/java-how-to-get-thread-id-from-a-thread-pool
    public static long getIdentificadorHiloActual() {
        return Thread.currentThread().getId();
    }
    
    //http://stackoverflow.com/questions/3342651/how-can-i-delay-a-java-program-for-a-few-seconds
    public static void dormirHilo(long milisegundos) {
        try {
            //Thread.sleep(1000);
            Thread.sleep(milisegundos);
        } catch(InterruptedException ex) {
            Thread.currentThread().interrupt();
        }
    }
}
